package org.example.backend.Module.System.Role.Controller;

import org.example.backend.Base.Response.JsonResult;
import org.example.backend.Base.Response.StatusCode;
import org.example.backend.Module.System.Role.Pojo.Entity.Role;
import org.example.backend.Module.System.Role.Service.RoleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/v1/role")
public class RoleController {

    @Resource
    private RoleService roleService;

    @GetMapping("/get/{id}")
    public JsonResult get(@PathVariable Integer id) {
        Role role = this.roleService.getRole(id);

        return role != null ? JsonResult.ok(role) : new JsonResult(StatusCode.DATA_UNEXISTS);
    }
}
